# Homework Assignment 1
# Megan Tienjaroonkul (mtienjar)
# Simulate Simmon's Situation B
# Addition of 10 more observations per cell

SituationB <- function(pval){
# Group 1 (Generate random data for sample size 20)
Liking1 <- rnorm(20,0,1) # Generate Normal random variables with mean=0 and sd=1
Extend1 <- rnorm(10,0,1) # Generate addtional Normal random variables
Extended1 <- c(Liking1, Extend1) # Add extension to initial data

# Group 2 (Generate Comparative set)
Liking2 <- rnorm(20,0,1) # Generate Normal random variables with mean=0 and sd=1
Extend2 <- rnorm(10,0,1) # Generate addtional Normal random variables 
Extended2 <- c(Liking2, Extend2) # Add extension to initial data

# Two-sample t-test
t.test1 <- t.test(Liking1, Liking2, var.equal=TRUE) # Two sample t-test
t.test2 <- t.test(Extended1, Extended2, var.equal=TRUE)

# signif=1 if at least one test gives p<pval, 0 otherwise
signif <- ifelse(t.test1$p.value<pval|
                   t.test2$p.value<pval,
                   1,0)

 return(signif) # Value Returned by function
}
